﻿using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;

namespace Vosc.Coff
{
	// Token: 0x02000020 RID: 32
	public class Out2Hex
	{
		// Token: 0x060000C7 RID: 199 RVA: 0x0000CFA4 File Offset: 0x0000B1A4
		private Out2Hex()
		{
		}

		// Token: 0x060000C8 RID: 200 RVA: 0x0000CFAC File Offset: 0x0000B1AC
		public static string Convert(string outfileName)
		{
			if (string.IsNullOrEmpty(outfileName) || !File.Exists(outfileName) || !outfileName.EndsWith(".out", true, null))
			{
				return null;
			}
			try
			{
				string text = Application.StartupPath + "\\OutToHexTool";
				Random random = new Random();
				string text2 = DateTime.Now.ToString("yyyyMMddHHmmss") + random.Next(1, 100).ToString() + ".hex";
				Process process = Process.Start(new ProcessStartInfo(text + "\\hex2000.exe")
				{
					Arguments = string.Format("\"{0}\"{1}\"{2}\"", outfileName, " -a -boot -sci8 -o ", text2),
					CreateNoWindow = true,
					UseShellExecute = false,
					WorkingDirectory = text
				});
				process.WaitForExit();
				if (process.ExitCode == 0)
				{
					process.Close();
					return text + "\\" + text2;
				}
				process.Close();
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex.Message + ex.StackTrace);
			}
			return null;
		}
	}
}
